package com.lwl.blog.utils;

import org.apache.ibatis.session.SqlSession;

public class SqlSessionThreadLocal {
    //使用threadlocal保存sqlsession
    private  static  ThreadLocal<SqlSession> threadLocal= new ThreadLocal<>();

    //将sqlsession添加到threadlocal中
    public static void set(SqlSession sqlSession){
        threadLocal.set(sqlSession);
    }

    // 从ThreadLocal获取SqlSession
    public static SqlSession get(){
       return threadLocal.get();
    }

    public static void  remove(){
        threadLocal.remove();
    }

}
